/**
 * Created by zxd on 2017/11/1.
 */
$(function(){

    //初始化日期控件
    $('#bt, #et').datetimepicker({
        language: 'zh-CN',
        format: 'yyyy-mm-dd',
        autoclose: true,
        minuteStep: 1,
        minView: "month"
    });

    loadDatas()
});

//加载数据
function loadDatas(s){

    if(s=="search"){
        $("#page").val("");
    }
    //页码
    var page = $("#page").val();
    //一页显示的条数
    var pageSize = 40;
    //管理员
    var gm = $("#gm").val();
    //操作开始时间
    var begin = $("#begin_time").val();
    //操作结束时间
    var end = $("#end_time").val();
    //操作内容
    var cz_value = $("#cz_value").val();
    //操作IP
    var cz_ip=$("#cz_ip").val();

    $.ajax({
        type:"post",
        data:{"page":page,"pageSize":pageSize,"begin":begin, "end":end, "gm":gm,"cz_value":cz_value,"cz_ip":cz_ip },
        url:"../../../php/sys/admin/loadAdminDoLog.php",
        beforeSend: function(){
            $("#load").css("display","block");
        },success:function(msg){

            $("#load").css("display","none");

            //console.log(msg);
            //return;
            var datas = msg.records;
            var html = "";

            if(datas.length==0){


                html += "<tr><td colspan='9' align='center'>没查询到符合条件的数据~</td></tr>";
            }else{

                for(var i=0;i<datas.length;i++){
                    html += "<tr>";
                    html += "<td>"+datas[i].id+"</td>";//id
                    html += "<td>"+datas[i].adminname+"</td>";//管理员
                    html += "<td>"+datas[i].cz_value+"</td>";//操作内容
                    html += "<td>"+datas[i].time+"</td>";//操作时间
                    html += "<td>"+datas[i].czip+"</td>";//操作ip
                    html += "</tr>";
                }

            }
            $("#databody").html(html);


            //分页数据
            var pageInfos = msg.pageInfo;
            //总条数
            var allCount = pageInfos[0].count;
            $("#count").html(allCount);
            //总页数
            var allPage = Math.ceil(allCount/pageSize);
            if(allPage==0){
                allPage = 1;
            }
            //当前页码
            var now = pageInfos[0].page;

            $("#page").val(now);
            $("#nowPage").html(now);
            $("#allPage").html(allPage);
            $("#pageIpu").val("");

        },error:function(msg){
            alert("连接出错！");
        }











    });


}

function findAll(s){
    $("#load").css("display","block");

    $("#reset").click();

    loadDatas(s);
}